package yawning.mew.bear;

import yawning.mew.sim.SimulationEvent;

public class BerserkProcEvent extends SimulationEvent {
	BearThreatSimulator mState;

	BerserkProcEvent(BearThreatSimulator state) {
		super(state.mSimEngine);

		mState = state;
	}

	public void onTrigger() {
		if (mState.mSimEngine.getRandom().nextBoolean(mState.mModel.pBerserkProc)) {
			if (this.isUp()) mNrBerserkProcOverwrites++;

			if (mState.mIsLogging) mState.mLog.log("Berserk Proc\n");
			mState.mMangleAction.onBerserk();

			mNrBerserkProcs++;
			schedule(mState.mModel.berserkProcBuffDuration);
		}
	}

	public void onConsume() {
		if (this.isUp()) {
			this.cancel();
		}
	}

	int mNrBerserkProcs = 0;
	int mNrBerserkProcOverwrites = 0;
}
